package com.jindy.module.statement.controller;


import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.core.page.TableDataInfo;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.statement.domain.StatementExpenses;
import com.jindy.module.statement.service.StatementExpensesService;
import com.jindy.system.service.ISysUserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 结算机器费用Controller
 *
 * @author zhaoxi
 * @date 2023-01-05
 */
@Api(tags = "业务后台 - 结算机器费用管理 ")
@RestController
@RequestMapping("/module/statementExpenses")
@Validated
@Slf4j
public class StatementExpensesController extends BaseController {

    @Autowired
    private StatementExpensesService statementExpensesService;

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询结算机器费用数据列表
     */
//    @PreAuthorize("@ss.hasPermi('module:statementExpenses:list')")
    @GetMapping("/list")
    public TableDataInfo list(StatementExpenses statementExpenses){

        //        //添加权限
        //        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        //        filing.setUserId(sysUser.getUserId().toString());

        startPage();
        List<StatementExpenses> list = statementExpensesService.selectStatementExpensesList(statementExpenses);
        return getDataTable(list);
    }

    /**
     * 根据id查询结算机器费用信息
     */
//    @PreAuthorize("@ss.hasPermi('module:statementExpenses:id')")
    @GetMapping(value = "/{id}")
    public AjaxResult get(@PathVariable("id") Long id) {
        return AjaxResult.success(statementExpensesService.selectStatementExpensesById(id));
    }

    /**
     * 新增结算机器费用数据
     */
    @Log(title = "新增结算机器费用", businessType = BusinessType.INSERT)
//    @PreAuthorize("@ss.hasPermi('module:statementExpenses:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody StatementExpenses statementExpenses)
    {
        return toAjax(statementExpensesService.insertStatementExpenses(statementExpenses));
    }

    /**
     * 修改结算机器费用数据
     */
    @Log(title = "修改结算机器费用", businessType = BusinessType.UPDATE)
//    @PreAuthorize("@ss.hasPermi('module:statementExpenses:update')")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody StatementExpenses statementExpenses) {
        return toAjax(statementExpensesService.updateStatementExpenses(statementExpenses));
    }

    /**
     * 删除结算机器费用
     */
    @Log(title = "删除结算机器费用", businessType = BusinessType.DELETE)
//    @PreAuthorize("@ss.hasPermi('module:statementExpenses:delete')")
    @DeleteMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(statementExpensesService.deleteStatementExpensesById(id));
    }

    /**
     * 批量删除
     */
    @Log(title = "批量删除", businessType = BusinessType.DELETE)
//    @PreAuthorize("@ss.hasPermi('module:statementExpenses:deletes')")
    @DeleteMapping("/{ids}")
    public AjaxResult removes(@PathVariable Long[] ids)
    {
        return toAjax(statementExpensesService.deleteStatementExpensesByIds(ids));
    }
}
